Repository navigation
Restore MTP startup diagnostics under dotnet test - #11971
Conversation
Write early warning and error diagnostics to the console before the dotnet test connection exists, preserving normal pipe suppression and negotiated forwarding. Add native-CLI regressions and compatibility guards. Fixes #11964. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: fadefeee-c287-4412-8c04-6b0942981e1f
There was a problem hiding this comment.
🟢 Approval recommended
The narrow fallback preserves existing protocol behavior, and focused regression coverage supports the change with no unresolved blocking findings.
0 open findings
What changed in this PR
Restores MTP startup diagnostics under native dotnet test, addressing #11964 without changing handshake timing or exit codes.
Changes:
- Writes warnings and errors to the console when no dotnet-test connection is registered.
- Adds regression coverage for four startup-validation failures.
- Strengthens checks that connected hosts keep stdout and stderr empty.
Test-value evidence: For revision bc3491eecf137534f2b76584f8e7db182b920188, the PR reports 8 passing unit cases and 7 passing acceptance cases, with targeted failures without the fix. These execution artifacts were not independently inspected; the supplied assertions statically support regression detection.
🟢 Confidence at a glance — MTP startup diagnostics
The fallback is narrowly scoped, preserves connected-protocol behavior, and has focused regression assertions. Reported execution was Windows-only.
| File | Description |
|---|---|
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/DotnetTestPassthroughOutputDeviceTests.cs | Verifies exact, once-only diagnostic console writes. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DotnetTestPipe/DotnetTestPipeStartupErrorTests.cs | Covers four startup failures through native dotnet test. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DotnetTestPipe/DotnetTestPipeDisplayMessageForwardingTests.cs | Checks connected hosts produce no console output. |
| src/Platform/Microsoft.Testing.Platform/OutputDevice/OutputDeviceManager.cs | Updates comments describing the startup fallback. |
| src/Platform/Microsoft.Testing.Platform/OutputDevice/DotnetTestPassthroughOutputDevice.cs | Adds console fallback for warnings and errors before connection registration. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🧪 Test quality review — PR #11971
Compared merge base 3ebfc8dc5cb48afe704cac6bce1b5ef0b834a12e with head
bc3491eecf137534f2b76584f8e7db182b920188. Evidence applies to this head, not
every intermediate commit.
Test-value evidence
Traced the production diff: DotnetTestPassthroughOutputDevice.ForwardDisplayMessageAsync now writes error/warning text to IServiceProvider.GetConsole() when no DotnetTestConnection is resolved (previously it silently dropped). OutputDeviceManager.cs's change is comment-only. The error/warning path is reached from TestHostBuilder.CommonServices.cs (ErrorMessageOutputDeviceData on command-line validation failures), confirming the test scenarios exercise a real production call chain.
| Contract / test case | Counterfactual | Without behavior | Correct implementation | Evidence / gap |
|---|---|---|---|---|
DotnetTestPassthroughOutputDeviceTests.DisplayAsync_WithDiagnosticButNoConnection_WritesToConsole(false/true) — warning/error written to console when no connection exists |
Pre-fix: early-return without touching IConsole |
static: predicts the strict-mock console.Verify(WriteLine, Times.Once) fails (no call made) |
static: predicts pass — WriteLine called exactly once with the exact message, VerifyNoOtherCalls guards against extra writes |
Static prediction only; PR description reports a matching executed counterfactual (2 failed→2 passed) but this review did not independently execute it |
DotnetTestPipeStartupErrorTests.DotnetTest_CommandLineValidationFailure_ShowsHostDiagnostic (4 DataRows: unknown option, missing extension, duplicate providers, malformed config) — startup diagnostic surfaces through native dotnet test before the pipe handshake |
Pre-fix: diagnostic dropped, only exit code 5 observed | static: predicts AssertOutputContains(expectedDiagnostic) fails on the dotnet test-driven run (direct-host run already passed pre-fix since it doesn't go through the pipe device) |
static: predicts pass — exit code InvalidCommandLine plus diagnostic text on both the direct-host and dotnet test-wrapped runs, and Usage {AssetName} is absent from stdout |
Static prediction only; PR description reports a matching executed counterfactual (4 failed→4 passed) but this review did not independently execute it |
DotnetTestPipeDisplayMessageForwardingTests.DotnetTestPipe_WhenSdkSupports130_* / *_WhenSdkOnlySupports120_* — connected hosts (protocol 1.2.0 and 1.3.0) must still produce no direct console output |
Refactor/strengthening: the fallback is correctly gated on "no connection" so a connected host's warnings/errors still route only through the pipe, never the console | not applicable — strengthening addition to already-passing tests; no connection path exists to resolve to a console write | executed-equivalent static prediction: pass — StandardOutput/StandardError both string.Empty |
New negative assertions guard against the console fallback firing when a connection is registered; a plausible regression (e.g. an inverted or unconditioned null-check) would be caught here |
No unassessed contract groups; the two changed source files map fully to the three test files above.
🧵 Parallel safety
STATUS: CLEAN (delegated to parallel-safety-reviewer). Microsoft.Testing.Platform.Acceptance.IntegrationTests runs MethodLevel parallelization; Microsoft.Testing.Platform.UnitTests has no assembly-level parallelization. The new DotnetTestPipeStartupErrorTests's 4 DataRow cases each call TestAsset.GenerateAssetAsync with a shared AssetName constant, but TestAsset always allocates a fresh randomized TempDirectory, so concurrent DataRow executions build to physically distinct bin/obj trees — no [DoNotParallelize] is needed. DotnetCli.RunAsync passes workingDirectory per-process (never mutates a shared CWD), and the one relative path (modulePath) resolves against that per-process working directory. No findings (Critical=0, High=0, Warning=0, Info=0).
Per-test assessment
Pseudo-mutation evidence below consists of static predictions, not executed mutation results.
| Result | Quality | Test | Notes | How to improve |
|---|---|---|---|---|
| Pass | A (90–100) | new DotnetTestPassthroughOutputDeviceTests. |
Strict mock verifies exact message written exactly once; VerifyNoOtherCalls rules out extra writes. |
None |
| Pass | A (90–100) | new DotnetTestPipeStartupErrorTests. |
Exit code, diagnostic text, and absence of leaked usage text are all checked across both entry points. | None |
| Pass | A (90–100) | mod DotnetTestPipeDisplayMessageForwardingTests. |
New assertions confirm connected hosts stay silent on stdout/stderr, complementing existing forwarding checks. | None |
| Pass | A (90–100) | mod DotnetTestPipeDisplayMessageForwardingTests. |
Same console-silence guard added for the legacy-protocol (1.2.0) path. | None |
This advisory review is heuristic and non-blocking.
Re-run the combined review with /review-tests, or only the parallel-safety
specialist with /parallel-audit.
🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · 327.4 AIC · ⌖ 9.77 AIC · ⊞ 22.4K · ◷
This comment has been minimized.
This comment has been minimized.
|
Final test-triage resolution — Azure Pipelines build 1637970 This supersedes the earlier preliminary comment from the Linux Release leg. 1. Aspire NU1902 restore failure (Linux Release) — not actionable against this PR
PR #11971 only touches 2. Windows Release leg — The pipeline timeline shows this test failed on the Windows Release leg, but the 3. Other Windows failures (retry-probe assets) — expected, not defects
No issue created: the only unresolved signal (HangDumpTests) lacks evidence due to the missing Windows Release artifact, and the Aspire/NU1902 failure is unrelated to this PR's diff. No durable, actionable, PR-attributable regression was identified.
|
Pull request
Summary
Restore MTP startup diagnostics under native
dotnet test. Command-line validation can fail before the pipe connection exists, leaving the SDK with only exit code 5 and no explanation.Fixes #11964.
Design and decision record
The issue investigation provides the rationale for this regression fix; no separate feature design record is needed.
Write warning/error diagnostics through the existing console service only when no dotnet-test connection is registered. Preserve the early-host/no-handshake lifecycle and exit code 5 rather than moving connection establishment ahead of validation. Once connected, negotiated forwarding and legacy-protocol suppression are unchanged; ordinary informational output remains suppressed.
Demonstration
Reproduced with SDK 10.0.402 and MSTest 4.5.1. Keeping that SDK/framework and consuming locally packed MTP/MSBuild 2.6.0-dev restores the diagnostic:
The transcript abbreviates surrounding SDK summary/path lines; both commands exited 5. Text is clearer than screenshots for this diagnostic-only change.
Validation and regression proof
Tested source: base
3ebfc8dc5cb48afe704cac6bce1b5ef0b834a12eplus the changes committed asbc3491eecf137534f2b76584f8e7db182b920188. Committed source/test bytes were verified unchanged after validation.Passed locally: all five MTP package TFMs; 8 net8.0 unit cases and 7 net11.0 acceptance cases, all Release, with no failures or skips. Acceptance discovery and the execution verifier reconciled all seven expected cases. TRX, JUnit, and CTRF reports were parsed and matched the executed counts.
The real shipping SDK 10.0.402 also passed/discovered the one-test normal consumer, displayed diagnostics for unknown options, missing extension packages and
-m:4, and correctly aggregated one passing module with one invalid module: parent exit 5, one passing test, and one valid-module TRX. It was not necessary to change the SDK or transfer the issue.Recorded commands and outcomes
Repository SDK:
12.0.100-alpha.1.26509.101, bootstrapped througheng\build.ps1. Commands ran from the task worktree root with process-localDOTNET_ROOTpointing to.dotnetand MSBuild server reuse disabled. Variables below abbreviate the original absolute paths to the same repository result directories.Baseline acceptance used the same selection and assertions against the separately packed pre-fix product, with results in
startup-acceptance-red-proven: exit 2, four intended missing-diagnostic assertion failures and three passing preservation cases.The final unit counterfactual substituted the original early-return behavior during compilation in isolated outputs, retaining the exact final tests.
$comparisonTargetsdenotes the task-ownedUseBaselineOutputDevice.targetsfile which replaced only that compile input:The counterfactual import produced nonfatal duplicate-import warnings; detection came from the two executed assertions, not those warnings or setup failures.
Baseline/fixed packages used isolated consumer caches. All four generated acceptance DLLs matched the fixed packed payload; the shipping SDK consumer's cached nupkg and executed DLL were also hash-verified.
2F3A3659090AD9E7F3CF04FAAF5E6FC22E2DDA71466E95A3BA87274ECD29CB28DD6682477FC9499C6A745FE87ADA97F82F6C26974823C329C2104BFCB61723FBLogs, TRX/JUnit/CTRF reports, package provenance and archived consumer restore metadata are retained in the Copilot session; they are not published CI artifacts.
Limitations: Windows-only local execution; no remote CI, Ubuntu or servicing-branch validation. A broader Windows solution pack with UAP deliberately excluded failed the MSTest package file-count audit because the expected UAP assets were absent. That attempt is not counted as successful full-solution packaging; the owning MTP package build passed.
Test-value evidence
DotnetTest_CommandLineValidationFailure_ShowsHostDiagnostic:StartupError_UnknownOption,StartupError_MissingExtension,StartupError_DuplicateProviders,StartupError_MalformedConfigurationDisplayAsync_WithDiagnosticButNoConnection_WritesToConsole(False/True)